package com.toidep.entities;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

import android.util.Log;

import com.toidep.api.ParseJSON;
import com.toidep.config.Constants;
import com.toidep.utilities.StringUtility;

public class AlbumEntity {

	private String id;
	private String name;
	private String modelId;
	private String modelName;
	private String modelIcon;
	private String display;
	private String thumbs;
	private String totalView;
	private String totalComment;
	private String totalGallery;
	
	private String caption;
	private String user_id;
	private String status;
	private String hot;
	private String top;
	private String totalLike;
	private String metaKeywork;
	private String metaDescription;
	private String pageTitle;
	private String created;
	private String updated;
	private String deleted;
	private ArrayList<GalleryEntity> galleries;
	private ArrayList<TagEntity> tags;
	
	private boolean isPayment; 
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getModelId() {
		return modelId;
	}
	public void setModel_id(String model_id) {
		this.modelId = model_id;
	}
	public String getModelName() {
		return modelName;
	}
	public void setModelName(String modelName) {
		this.modelName = modelName;
	}
	public String getModelIcon() {
		return modelIcon;
	}
	public void setModelIcon(String modelIcon) {
		this.modelIcon = modelIcon;
	}
	public String getDisplay() {
		return display;
	}
	public void setDisplay(String display) {
		this.display = display;
	}
	public String getThumbs() {
		return thumbs;
	}
	public void setThumbs(String thumbs) {
		this.thumbs = thumbs;
	}
	public String getTotalView() {
		return totalView;
	}
	public void setTotalView(String totalView) {
		this.totalView = totalView;
	}
	public String getTotalComment() {
		return totalComment;
	}
	public void setTotalComment(String totalComment) {
		this.totalComment = totalComment;
	}
	public String getTotalGallery() {
		return totalGallery;
	}
	public void setTotalGallery(String totalGallery) {
		this.totalGallery = totalGallery;
	}
	public String getCaption() {
		return caption;
	}
	public void setCaption(String caption) {
		this.caption = caption;
	}
	public String getUser_id() {
		return user_id;
	}
	public void setUser_id(String user_id) {
		this.user_id = user_id;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public String getHot() {
		return hot;
	}
	public void setHot(String hot) {
		this.hot = hot;
	}
	public String getTop() {
		return top;
	}
	public void setTop(String top) {
		this.top = top;
	}
	public String getTotalLike() {
		return totalLike;
	}
	public void setTotalLike(String totalLike) {
		this.totalLike = totalLike;
	}
	public String getMetaKeywork() {
		return metaKeywork;
	}
	public void setMetaKeywork(String metaKeywork) {
		this.metaKeywork = metaKeywork;
	}
	public String getMetaDescription() {
		return metaDescription;
	}
	public void setMetaDescription(String metaDescription) {
		this.metaDescription = metaDescription;
	}
	public String getPageTitle() {
		return pageTitle;
	}
	public void setPageTitle(String pageTitle) {
		this.pageTitle = pageTitle;
	}
	public String getCreated() {
		return created;
	}
	public void setCreated(String created) {
		this.created = created;
	}
	public String getUpdated() {
		return updated;
	}
	public void setUpdated(String updated) {
		this.updated = updated;
	}
	public String getDeleted() {
		return deleted;
	}
	public void setDeleted(String deleted) {
		this.deleted = deleted;
	}
	
	public ArrayList<GalleryEntity> getGalleries() {
		return galleries;
	}
	public void setGalleries(ArrayList<GalleryEntity> galleries) {
		this.galleries = galleries;
	}
	public ArrayList<TagEntity> getTags() {
		return tags;
	}
	public void setTags(ArrayList<TagEntity> tags) {
		this.tags = tags;
	}
	/**
	 * @return the isPayment
	 */
	public boolean isPayment() {
		return isPayment;
	}
	/**
	 * @param isPayment the isPayment to set
	 */
	public void setPayment(boolean isPayment) {
		this.isPayment = isPayment;
	}
	public void setInfo(JSONObject jsonObject) {
		
		 this.id = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_ID);
		this.name = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_NAME);
		
		this.modelId = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_MODEL_ID);
		this.modelName = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_MODEL_NAME);
		this.modelIcon = StringUtility.parseImageUrl(ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_MODEL_ICON));
		this.caption = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_CAPTION);
		this.created = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_CREATED);
		
		this.display = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_DISPLAY);
		this.thumbs = StringUtility.parseImageUrl(ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_THUMBS));
		this.totalView = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_TOTAL_VIEW);
		Log.d("Q_Album", "views=" +  ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_TOTAL_VIEW));
		this.totalComment = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_TOTAL_COMMENT);
		this.totalGallery = ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_TOTAL_GALLERY);
		
		JSONArray tagArray = ParseJSON.getJsonArray(jsonObject, Constants.PARAM_RESPONSE_TAGS);
		this.tags = ParseJSON.getAllTagObject(tagArray);
		
		JSONArray galleryArray = ParseJSON.getJsonArray(jsonObject, Constants.PARAM_RESPONSE_GALLERIES);
		this.galleries = ParseJSON.getAllGalleryObject(galleryArray);
		
		this.isPayment = (ParseJSON.getIntValue(jsonObject, "is_fee") == 1);
	}
	
	//QuangLM_20140507 fix bug #219
	  //start
	public void setInfoFix219(JSONObject jsonObject) {
		setInfo(jsonObject);
		this.thumbs = StringUtility.parseImageUrl(ParseJSON.getStringValue(jsonObject, Constants.PARAM_RESPONSE_THUMB));
	}
	  //end
	
}
